const dayjs = require("dayjs")

const realTime = dayjs().format("YYYY-MM-DD")

module.exports = {
  apps: [
    {
      name: "main",
      script: "./dist_main/index.cjs",
      watch: "dist_main",

      // log相关
      log_file: `./logs/pm2/run/${realTime}.log`,
      log_date_format: "YYYY-MM-DD HH:mm:ss",
      post_update: ["pnpm i"],
      autorestart: true,
      restart_delay: 1 * 60 * 1000,

      // 指数退避
      exp_backoff_restart_delay: 60 * 1000,
    },

    {
      name: "web",
      script: "./dist_web/web/index.cjs",
      watch: "dist_web",
      // log相关
      log_file: `./logs/pm2/web/${realTime}.log`,
      log_date_format: "YYYY-MM-DD HH:mm:ss",
      autorestart: true,
      restart_delay: 1 * 60 * 1000,

      // 指数退避
      exp_backoff_restart_delay: 60 * 1000,
    },
  ],
}
